package org.tb.acentweb.action;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import org.tb.acentweb.service.BookService;

public class GetBooksAction implements Action{
    
	private String[] books;
	
	public void setBooks(String[] books)
	{
		this.books = books;
	}
	
	public String[] getBooks()
	{
		return books;
	}
    
    public String execute() throws Exception
    {
    	String user = (String)ActionContext.getContext().getSession().get("user");
    	
    	if(user != null && user.equals("good"))
    	{
    		BookService bs = new BookService();
    		setBooks(bs.getBooks());
    		return SUCCESS;
    	}
    	else
    	{
    		return LOGIN;
    	}
    }
}
